package com.yc.web.servlets;

import com.yc.bean.Student;
import com.yc.model.JsonModel;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @author zwei
 * @create 2024-05-15 15:28
 */
@WebServlet("/student.action")
public class StudnetServlet extends BaseServlet{
    protected void getAllStudent(HttpServletRequest req, HttpServletResponse resp) throws InvocationTargetException, InstantiationException, IllegalAccessException, IOException {
        JsonModel jm=new JsonModel();
        String creator=req.getParameter("creator");
        System.out.println(creator);
        List<Student>list=dbHelper.select(Student.class,"select*from student");
        if (list.size()>0){
            jm.setCode(1);
            jm.setObj(list);
        }else {
            jm.setError("数据获取失败");
            jm.setCode(0);
        }
        super.writeJson(jm,resp);
    }
}
